package com.detrum;

/**
 * Created by chenlei on 2017/6/9.
 */

public class NFSVideo {
    /**
     * 初始化
     *
     * @return 根据返回值判断是否初始化成功
     */
    public static native int init();    //初始化
    public static native void destroyContext();

    public static native int mount(String server, String exportname, int nfsIndex);
    public static native int opendir(String path, int nfsIndex);
    public static native int chdir(String path, int nfsIndex);
    public static native int rmdir(String path, int nfsIndex);
    public static native int readdir(byte[] Name, byte[] Mode, long[] mtime, long[] size, int nfsIndex);
    public static native int closedir(int nfsIndex);

    public static native int open(String path, int flag, int nfsIndex);
    public static native int create(String path, int nfsIndex);
    public static native int write(byte[] buff, int buf_len, int nfsIndex);
    public static native int unlink(String path, int nfsIndex);
    public static native int read(byte[] buff, int buf_len, int nfsIndex);
    public static native int lseek(long offset, int whence, int nfsIndex);
    public static native int close(int nfsIndex);

    public static native int avOpen(String path, int nfsIndex);
    public static native int avGetStreamCount(int nfsIndex);
    public static native int avGetStream(int index, int[] stream_type, int nfsIndex);

    public static native int avGetVideoStreamInfo(int index, int[] codec_id, int[] profile, int[] resolution,
                                                  int[] time_base, int[] fps,long[] start_time, long[] nb_frame, long[] total_time, int nfsIndex);

    public static native int avGetStreamExtraData(int nfsIndext,int index,byte[] Buff, int[] buf_len);

    public static native int avGetAudioStreamInfo(int index, int[] codec_id, int[] profile, int[] sample_rate, int[] sample_format,
                                                  int[] channel_num, long[] channel_layout, long[] frame_size, long[] total_time, int nfsIndex);

    public static native int avGetFrame(int[] streamID, byte[] buff, int[] buf_len, long[] dts, long[] pts, int nfsIndex,int[] flag);
    public static native int avSeek(long timestamp, int dir,int nfsIndex);
    public static native int avClose(int nfsIndex);

    public static native int release(int nfsIndex);
    static {
        System.loadLibrary("nfs");
        System.loadLibrary("ijkffmpeg");
        System.loadLibrary("NFSVideo");
    }
}
